<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改用户信息</title>
<link rel="stylesheet" href="${path}/static/lib/layui/css/layui.css">
<style type="text/css">
	.main_div{
		margin : 15px;
	}
</style>
</head>
<body>
  	<div class="main_div">
		<form id="form_add" onsubmit="return false" class="layui-form layui-form-pane" action="">
		  <input type="hidden" id="uid" name="uid" value = "${user.uid}"/>
		  <div class="layui-form-item">
		    <label class="layui-form-label">电话</label>
		    <div class="layui-input-block">
		      <input type="text" id="phone" name="phone" autocomplete="off" value="${user.phone}" placeholder="${user.phone}" class="layui-input">
		    </div>
		  </div>

		<div class="layui-form-item">
		    <label class="layui-form-label">用户名</label>
		    <div class="layui-input-block">
		      <input type="text" id="name" name="name" autocomplete="off" value="${user.name}" placeholder="${user.name}" class="layui-input">
		    </div>
		</div>

			<div class="layui-form-item">
				<label class="layui-form-label">密码</label>
				<div class="layui-input-block">
					<input type="password" id="password" name="password" autocomplete="off" value="${user.password}" placeholder="${user.password}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">交易密码</label>
				<div class="layui-input-block">
					<input type="text" id="tradePwd" name="tradePwd" autocomplete="off" value="${user.tradePwd}" placeholder="${user.tradePwd}" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开户银行</label>
				<div class="layui-input-block">
					<input type="text" id="bank" name="bank" autocomplete="off" value="${user.bank}" placeholder="${user.bank}" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开户姓名</label>
				<div class="layui-input-block">
					<input type="text" id="bankName" name="bankName" autocomplete="off" value="${user.bankName}" placeholder="${user.bankName}" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">开户账号</label>
				<div class="layui-input-block">
					<input type="text" id="bankAccount" name="bankAccount" autocomplete="off" value="${user.bankAccount}" placeholder="${user.bankAccount}" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">冻结状态</label>
				<div class="layui-input-block">
					<input type="text" id="freeze" name="freeze" autocomplete="off" value="${user.freeze}" placeholder="${user.freeze}" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">上级</label>
				<div class="layui-input-block">
					<input type="text" id="superior" name="superior" autocomplete="off" value="${user.superior}" placeholder="${user.superior}" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">比尔币</label>
				<div class="layui-input-block">
					<input type="text" id="diamond" name="diamond" autocomplete="off" value="${user.diamond}" placeholder="${user.diamond}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">积分</label>
				<div class="layui-input-block">
					<input type="text" id="vouchers" name="vouchers" autocomplete="off" value="${user.vouchers}" placeholder="${user.vouchers}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">金额</label>
				<div class="layui-input-block">
					<input type="text" id="money" name="money" autocomplete="off" value="${user.money}" placeholder="${user.money}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">等级</label>
				<div class="layui-input-block">
					<input type="text" id="grade" name="grade" autocomplete="off"
					<c:choose>
						<c:when test="${user.grade == 1}">
						   placeholder="会员"
						</c:when>
						<c:when test="${user.grade == 2}">
						   placeholder="服务商"
						</c:when>
						<c:when test="${user.grade == 3}">
						   placeholder="优秀服务商"
						</c:when>
						<c:when test="${user.grade == 4}">
						   placeholder="高级服务商"
						</c:when>
						<c:otherwise>
						   placeholder="啥也不是！"
						</c:otherwise>
					</c:choose>
						   class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">个人业绩</label>
				<div class="layui-input-block">
					<input type="text" id="rechargeTotal" name="rechargeTotal" autocomplete="off" value="${user.rechargeTotal}" placeholder="${user.rechargeTotal}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">充值单数</label>
				<div class="layui-input-block">
					<input type="text" id="buyNumber" name="buyNumber" autocomplete="off" value="${user.buyNumber}" placeholder="${user.buyNumber}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">首次充值时间</label>
				<div class="layui-input-block">
					<input type="text" id="rechargeTime" name="rechargeTime" autocomplete="off" value="${user.rechargeTime}" placeholder="${user.rechargeTime}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">注册时间</label>
				<div class="layui-input-block">
					<input type="text" id="registerTime" name="registerTime" autocomplete="off" value="${user.registerTime}" placeholder="${user.registerTime}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">总代理</label>
				<div class="layui-input-block">
					<input type="text" id="generalAgent" name="generalAgent" autocomplete="off" value="${user.generalAgent}" placeholder="${user.generalAgent}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">收益百分比</label>
				<div class="layui-input-block">
					<input type="text" id="earningsProportion" name="earningsProportion" autocomplete="off" value="${user.earningsProportion}" placeholder="${user.earningsProportion}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">收货地址</label>
				<div class="layui-input-block">
					<input type="text" id="address" name="address" autocomplete="off" value="${user.address}" placeholder="${user.address}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">显示</label>
				<div class="layui-input-block">
					<input type="text" id="display" name="display" autocomplete="off" value="${user.display}" placeholder="${user.display}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">挂卖时间</label>
				<div class="layui-input-block">
					<input type="text" id="guamaiTime" name="guamaiTime" autocomplete="off" value="${user.guamaiTime}" placeholder="${user.guamaiTime}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">购物限制</label>
				<div class="layui-input-block">
					<input type="text" id="astrict" name="astrict" autocomplete="off" value="${user.astrict}" placeholder="${user.astrict}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">钱包地址</label>
				<div class="layui-input-block">
					<input type="text" id="moneyAddress" name="moneyAddress" autocomplete="off" value="${user.moneyAddress}" placeholder="${user.moneyAddress}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">编码</label>
				<div class="layui-input-block">
					<input type="text" id="twoCode" name="twoCode" autocomplete="off" value="${user.twoCode}" placeholder="${user.twoCode}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">编码</label>
				<div class="layui-input-block">
					<input type="text" id="freezeDiamond" name="freezeDiamond" autocomplete="off" value="${user.freezeDiamond}" placeholder="${user.freezeDiamond}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">比特币</label>
				<div class="layui-input-block">
					<input type="text" id="fmoney" name="fmoney" autocomplete="off" value="${user.fmoney}" placeholder="${user.fmoney}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">是否领导人</label>
				<div class="layui-input-block">
					<input type="text" id="isld" name="isld" autocomplete="off" value="${user.isld}" placeholder="${user.isld}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">比特币价值</label>
				<div class="layui-input-block">
					<input type="text" id="moneybrtoal" name="moneybrtoal" autocomplete="off" value="${user.moneybrtoal}" placeholder="${user.moneybrtoal}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">当前有效单数</label>
				<div class="layui-input-block">
					<input type="text" id="curNumber" name="curNumber" autocomplete="off" value="${user.curNumber}" placeholder="${user.curNumber}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">冻结比特币</label>
				<div class="layui-input-block">
					<input type="text" id="freezeFmoney" name="freezeFmoney" autocomplete="off" value="${user.freezeFmoney}" placeholder="${user.freezeFmoney}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">报单币</label>
				<div class="layui-input-block">
					<input type="text" id="taxmoney" name="taxmoney" autocomplete="off" value="${user.taxmoney}" placeholder="${user.taxmoney}" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">报单中心</label>
				<div class="layui-input-block">
					<input type="text" id="taxcenter" name="taxcenter" autocomplete="off" value="${user.taxcenter}" placeholder="${user.taxcenter}" class="layui-input">
				</div>
			</div>
		  <input type="button" class="layui-btn" onclick="submitForm()" value="提交"/>
		</form>
	</div>


	<script src="${path}/static/back/js/jquery.min.js?v=2.1.4"></script>
	<script src="${path}/static/common/mylayer.js"></script>
	<script src="${path}/static/common/util.js"></script>
	<script src="${path}/static/lib/layui/layui.js"></script>
	<script src="${path}/static/lib/kindeditor/kindeditor.js"></script>
	<script src="${path}/static/lib/kindeditor/lang/zh_CN.js"></script>

	<script>
	 	layui.config({
		    base : '${path}/static/lib/'
		  }).extend({
		    selectM: './layui_extends/selectM'
		  }).use(['form','upload','selectM'],function(){
		  	var form = layui.form;
		  	var upload = layui.upload;
		  	var selectM = layui.selectM;
		  	
		  	$.ajax({
				url : '${path}/user/selectUserAndRoles',
				type : 'POST',
				data : {"userId" : "${param.userId}"},
				dataType : 'json',
				success : function(resp) {
					if(resp.code == util.SUCCESS) {
						mylayer.success(resp.msg);
						var user = resp.data["user"];
						var allRoles = resp.data["allRoles"];
						var selectIds = resp.data["selectIds"];
						$("#id").val(user.id);
						$("#name").val(user.name);
						$("#trueName").val(user.trueName);
						$("#email").val(user.email);
						$("#phone").val(user.phone);
						$("#password").val(user.password);
						
						 //多选标签-基本配置
					    var tagIns = selectM({
					      //元素容器【必填】
					      elem: '#roles'
					      //候选数据【必填】
					      ,data: allRoles
					      //默认值
					      ,selected: selectIds
					   	  // 默认最多选中5个
					      ,max : 100
					    });
					} else {
						mylayer.errorMsg(resp.msg);
					}
				}
			});
		});
		
		//ajax方式提交form表单
		function submitForm(){
			console.log("提交ing");
			$.ajax({
				url : '${path}/user/updateUser',
				data : $('#form_add').serialize(),
				type : 'POST',
				dataType : 'json',
				success : function(resp) {
					console.log(resp);
					if(resp.code == util.SUCCESS) {
						mylayer.success(resp.msg);
						var index = parent.layer.getFrameIndex(window.name);
						// js一个方法，定时器，1000毫秒之后自动执行function里面的代码
						setTimeout(function() {
							// 关闭弹出层
							parent.layer.close(index);
							// 刷新父页面
							window.parent.location.reload();
						}, 1000);
					} else {
						mylayer.errorMsg(resp.msg);
					}
				}
			});
		}

		
	</script>
</body>
</html>